hysop.tools.spectral_utils module¶
- class hysop.tools.spectral_utils.EnergyDumper(energy_parameter, io_params, fname, **kwds)[source]¶
Bases:
object
- class hysop.tools.spectral_utils.EnergyPlotter(energy_parameters, io_params, fname, fig_title=None, axes_shape=(1,), figsize=(15, 9), basex=10, basey=10, **kwds)[source]¶
Bases:
object
- class hysop.tools.spectral_utils.SpectralTransformUtils[source]¶
Bases:
object
Class that contains userfull methods for SpectralTransform setup.
- C2C_transforms = (FFT(1), IFFT(2))¶
- C2R_transforms = (IRFFT(4),)¶
- R2C_transforms = (RFFT(3),)¶
- R2R_transforms = (DCT_I(5), DCT_II(6), DCT_III(7), DCT_IV(8), IDCT_I(13), IDCT_II(14), IDCT_III(15), IDCT_IV(16), DST_I(9), DST_II(10), DST_III(11), DST_IV(12), IDST_I(17), IDST_II(18), IDST_III(19), IDST_IV(20))¶
- backward_transforms = (IFFT(2), IRFFT(4), IDST_I(17), IDST_II(18), IDST_III(19), IDST_IV(20), IDCT_I(13), IDCT_II(14), IDCT_III(15), IDCT_IV(16))¶
- classmethod boundaries_to_extensions(boundaries)[source]¶
Convert a BoundaryCondition pair tuple to a BoundaryExtension pair tuple.
- classmethod boundaries_to_transforms(boundaries, transformed_axes)[source]¶
Return a tuple of TransformType from a tuple of (left_boundaries, right_boundaries).
- classmethod boundary_to_extension(boundary)[source]¶
Convert a BoundaryCondition to a BoundaryExtension
- classmethod compute_wave_numbers(transform, N, L, ftype)[source]¶
Compute wave numbers of a given transform.
- cosine_transforms = (DCT_I(5), DCT_II(6), DCT_III(7), DCT_IV(8), IDCT_I(13), IDCT_II(14), IDCT_III(15), IDCT_IV(16))¶
- classmethod determine_input_dtype(output_dtype, *transforms)[source]¶
Compute input data type from output data type and list of backward transforms.
- classmethod determine_output_dtype(input_dtype, *transforms)[source]¶
Compute output data type from input data type and list of forward transforms.
- classmethod extension_to_transform(left_ext, right_ext, is_complex=False)[source]¶
Convert a BoundaryExtension pair to a TransformType.
- classmethod extensions_to_transforms(extensions, transformed_axes, is_complex=False)[source]¶
Convert a BoundaryExtension pair tuple to a TransformType tuple.
- forward_transforms = (FFT(1), RFFT(3), DST_I(9), DST_II(10), DST_III(11), DST_IV(12), DCT_I(5), DCT_II(6), DCT_III(7), DCT_IV(8))¶
- classmethod generate_wave_number(transform, axis, exponent)[source]¶
Create a new wavenumber. WaveNumbers are registered dummy symbols.
- classmethod generate_wave_numbers(*transforms)[source]¶
Generare a list of wave_numbers in transform order. Axis will match transform position.
- classmethod get_conjugate_inverse_transforms(*transforms)[source]¶
Get the conjugate inverse TransformType (ie. inverse for odd derivatives).
- classmethod get_inverse_transforms(*transforms)[source]¶
Get the inverse TransformType of a TransformType (for all input arguments).
- classmethod parse_expression(expr, replace_pows=True)[source]¶
Extract all wave_numbers from expression. If replace_pow is set, all wave_numbers powers will have their own symbol and are replace in expression (this allows to precompute wavenumber powers).
Returns parsed expression and a set of spectral transforms and a set of contained wave_numbers.
- sine_transforms = (DST_I(9), DST_II(10), DST_III(11), DST_IV(12), IDST_I(17), IDST_II(18), IDST_III(19), IDST_IV(20))¶
- hysop.tools.spectral_utils.make_multivariate_polynomial(Xl, Xr, lboundaries, rboundaries, N, order)[source]¶
Build a tensor product of polynomials satisfying boundary conditions on each axis.
lboundaries: np.ndarray of BoundaryCondition rboundaries: np.ndarray of BoundaryCondition other parameters: scalar or array_like of the same size as boundary arrays
All parameters are expanded to the size of the length of prescribed boundaries. See make_polynomial for more informations about parameters.
This method returns a tuple (P,Y) where:
P is a sympy expression representing a multivariate polynomials in variables Y = (y0, y1, …, yd)
P(Y) = P0(y0) * P1(y1) * … * Pd(yd)
*d = lboundaries.size-1 = rboundaries.size-1
- *P0 is a polynomial of order N[0] that satisfies (lboundaries[0], rboundaries[0])
on domain [Xl[0], Xr[0]] up to order order[0].
- *P1 is a polynomial of order N[1] that satisfies (lboundaries[1], rboundaries[1])
on domain [Xl[1], Xr[1]] up to order order[1].
.¶
. *Pd is a polynomial of order N[d] that satisfies (lboundaries[d], rboundaries[d])
on domain [Xl[d], Xr[d]] up to order order[d].
- hysop.tools.spectral_utils.make_multivariate_trigonometric_polynomial(Xl, Xr, lboundaries, rboundaries, N)[source]¶
Build a tensor product of trigonometric polynomials satisfying boundary conditions on each axis.
lboundaries: np.ndarray of BoundaryCondition rboundaries: np.ndarray of BoundaryCondition other parameters: scalar or array_like of the same size as boundary arrays
All parameters are expanded to the size of the length of prescribed boundaries. See make_trigonometric_polynomial for more informations about parameters.
This method returns a tuple (P,Y) where:
P is a sympy expression representing a multivariate trigonometric polynomials in variables Y = (y0, y1, …, yd)
P(Y) = P0(y0) * P1(y1) * … * Pd(yd)
*d = lboundaries.size-1 = rboundaries.size-1
- *P0 is a trigonometric polynomial of order N[0] that satisfies (lboundaries[0], rboundaries[0])
on domain [Xl[0], Xr[0]].
- *P1 is a trigonometric polynomial of order N[1] that satisfies (lboundaries[1], rboundaries[1])
on domain [Xl[1], Xr[1]].
.¶
. *Pd is a trigonometric polynomial of order N[d] that satisfies (lboundaries[d], rboundaries[d])
on domain [Xl[d], Xr[d]].
- hysop.tools.spectral_utils.make_polynomial(Xl, Xr, lboundary, rboundary, N, order)[source]¶
Build a polynom of order N-1 between on domain [Xl, Xr] that verifies prescribed left and right boundary conditions up to a certain order.
- Conditions:
Xl < Xr order >= 2 N > 2*order > 4
- Valid boundary conditions are:
(PERIODIC, PERIODIC) dPi/dxi(Xl) - dPi/dxi(Xr) = 0 (HDIRICHLET, HDIRICHLET) dPp/dxi(Xl) = dPp/dxi(Xr) = 0 for even derivatives (i%2==0) (HDIRICHLET, HNEUMANN) mix of the 2nd and 4th conditions (HNEUMANN, HDIRICHLET) mix of the 2nd and 4th conditions (HNEUMANN, HNEUMANN) dPi/dxi(Xl) = dPi/dxi(Xr) = 0 for odd derivatives (i%2==1)
Return (P, X) where P is a sympy expression that represent the polynomial and X is the corresponding sympy.Symbol.
- hysop.tools.spectral_utils.make_trigonometric_polynomial(Xl, Xr, lboundary, rboundary, N)[source]¶
Build a real trigonometric polynomial of order N-1 between on domain [Xl, Xr] that verifies prescribed left and right boundary conditions.
- Conditions:
Xl < Xr N >= 1
- Valid boundary conditions are:
(PERIODIC, PERIODIC) (HDIRICHLET, HDIRICHLET) (HDIRICHLET, HNEUMANN) (HNEUMANN, HDIRICHLET) (HNEUMANN, HNEUMANN)
Return (P, X) where P is a sympy expression that represent the polynomial and X is the corresponding sympy.Symbol.